function request(url, data) {
    return new Promise((resolve, reject)=>{
    	let params = Object.assign(data, {api: url});
        $.post("/api", data, function(res){
            resolve(res);
        });
    });
};



/*----------获取验证码---------*/
exports.user_getCode = (data={})=>{
	return request("/user/getCode", data);
};

/*----------用户登录---------*/
exports.user_login = (data={})=>{
	return request("/user/login", data);
};

/*----------商品详情---------*/
exports.product_detail = (id)=>{
    return request("/product/detail", {id});
};

/*----------购买记录--------*/
exports.product_orderRecode = (data={})=>{
    return request("/product/orderRecord", data);
};

/*----------添加收货地址-------*/
exports.address_add = (data={})=>{
    return request("/address/add", data);
};

/*----------创建订单--------*/
exports.order_create = (data={})=>{
    return request("/order/create", data);
};

/*----------订单列表----------*/
exports.order_list = (data={})=>{
    return request("/order/list", data);
};

/*----------获取商品列表--------*/
exports.product_query = (data={})=>{
    return request("/product/query", data);
};

/*----------工厂加盟-------*/
exports.shop_join = (data={})=>{
    return request("/shop/join", data);
};

exports.factory_join = (data={})=>{
    return request("/factory/join", data);
};

/*----------收货地址---------*/
exports.address_myList = (data={})=>{
    return request("/address/myList", data);
};

/*----------加工类目----------*/
exports.process_catList = ()=>{
    return request("process/catList", {});
};

/*----------款式列表--------*/
exports.process_styleList = (data={})=>{
    return request("process/styleList", data);
};

/*----------商品购买记录------*/
exports.product_orderRecord = (data={})=>{
    return request("/product/orderRecord", data);
};

/*----------获取评价列表------------*/
exports.product_rateList = (data={})=>{
    return request("/product/rateList", data);
};

/*----------发布需求--------*/
exports.process_demand = (data={})=>{
    return request("process/demand", data);
};







